package com.muye.dianli.fragment;

import java.io.File;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.muye.constant.C;
import com.muye.dianli.R;
import com.zvezda.android.utils.BaseUtils;
import com.zvezda.disply.utils.DisplayConfig;
import com.zvezda.disply.utils.DisplayConst;
import com.zvezda.disply.utils.DisplayManager;

/**
 * 商品详情页面ViewPager图片页面
 * 
 * @author TangChao
 *
 */
public class CommodityDetailViewPagerPictureFragment extends Fragment
{
	private String url;
	
	private String filePath;
	
	public String getUrl()
	{
		return url;
	}
	
	public void setUrl(String url)
	{
		this.url = url;
	}
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		filePath = C.FILE_PATH + "/DianLi";
		File file = new File(filePath);
		if (!file.exists())
		{
			file.mkdirs();
		}
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
	{
		View view = inflater.inflate(R.layout.commodity_detail_view_pager_picture_fragment, null);
		ImageView imageView = (ImageView) view.findViewById(R.id.image_view0);
		DisplayManager.getInstance().open(getActivity());
		DisplayConfig displayConfig = new DisplayConfig();
		displayConfig.url = url;
		displayConfig.path = BaseUtils.getFilePath(filePath, url);
		displayConfig.defaultRes = R.drawable.ic_launcher;
		displayConfig.w = 128;
		displayConfig.h = 128;
		displayConfig.angle = 10;
		displayConfig.zoomModel = DisplayConst.ZOOM_THUMBNAIL;
		displayConfig.imageView = imageView;
		DisplayManager.getInstance().display(displayConfig);
		return view;
	}
};
